<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("comctrls.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class update_edit extends Page
{
       public $Image1 = null;
       public $hfAutoId = null;
       public $memoRemarks = null;
       public $memoUpdate = null;
       public $dtpDate = null;
       public $Button2 = null;
       public $Submit = null;
       public $Label3 = null;
       public $Label2 = null;
       public $Label1 = null;
       function SubmitClick($sender, $params)
       {
       $query_up = "UPDATE prospects_updates_tbl
       SET date='".$this->dtpDate->Text."',
       updates='".$this->memoUpdate->Text."',
       jti_remark='".$this->memoRemarks->Text."'
       WHERE autoid='".$this->hfAutoId->getValue()."'";
       mysql_query($query_up) or die("UPDATE UPDATE ".mysql_error());

       echo '<script language=javascript>
       window.opener.location.reload();
       alert("Successfully Updated Record!");
       window.close();
       </script>';
       }

       function update_editCreate($sender, $params)
       {
       $autoid = $_GET['autoid'];
       if($autoid!=''&&$autoid!=null)
       $this->hfAutoId->setValue($autoid);

       $query_select = "SELECT * FROM prospects_updates_tbl WHERE autoid='".$this->hfAutoId->getValue()."'";
       $result_select = mysql_query($query_select) or die("SELECT UPDATES ".mysql_error());
       $row_select = mysql_fetch_array($result_select);
       $this->memoUpdate->Lines = array();
       $this->memoRemarks->Lines = array();
       $this->dtpDate->Text = $row_select['date'];
       $this->memoUpdate->Text = $row_select['updates'];
       $this->memoRemarks->Text = $row_select['jti_remark'];
       }

       function Button2JSClick($sender, $params)
       {

       ?>
       window.close();

       <?php

       }

}

global $application;

global $update_edit;

//Creates the form
$update_edit=new update_edit($application);

//Read from resource file
$update_edit->loadResource(__FILE__);

//Shows the form
$update_edit->show();

?>